- /* smmerror.cpp by K.Tsuru */
- /****************
- SNManager class
- error handler
- ******************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- #include "version.h"
-
- /**************************************************************************
- Definition in SNManager class
- enum SNErrorFlag {
- NO_ERR = 0, OVERFLOW_ERR, UNDERFLOW_ERR, DIVIDED_BY_ZERO, SIGN_ERR,
- NOT_CONVERGE, DOMAIN_ERR, OUT_OF_RANGE, RADIX_ERR, UNDEC_VALUE,
- SET_EFF_FIG, SYNTAX_ERR, FFT_ERR, TOO_LONG, TOO_LARGE_EXP,
- TLOSS_ERR, VERIFY, FATAL
- };
- ***************************************************************************/
- static const char* const ErrorMsg[]={
- SN_Lib_Version,
- "Overflow",
- "Underflow",
- "Divided by 0",
- "Sign", // XXAdd, XXSub must be same sign.
- "Series did not converge",
- "Domain", // Mathematical error
- "Out of range", // Not mathematical error but argument of function was out of range.
- "Radix",
- "Undecided number operation in substitution/output",
- "Usage of SetEffFig()", // SetEffFig(n);.... SetEffFig(0); || isA() != SN_MANEGER
- "Syntax", // "0.abcd.efg" in StringToNumber etc.
- "FFT", // LLMultFFT()
- "Given number was too long", // "abcdefg..." in StringToNumber etc.
- "Exponent is too large/small",
- "Effective figures lost",
- "Verification",
- "Fatal", // Constructor of SNumber class. figure[i] >= radix in CheckArray().
- "",
- };
-
- // function ID = 001
- void SNManager::ErrorHandler(int errID){
- if(errID > 0) fputs("\nError :", stderr);
- else fputs("\nWarning :", stderr);
- if( *place || (place!= NULL) ){
- fputs(place, stderr); fputc(' ',stderr);
- }
- fprintf(stderr,"%s. ID = %d\n", ErrorMsg[errorFlag], errID);
- if(errID > 0) exit(EXIT_FAILURE);
- }
-
- // function ID = 008
- void SNManager::SetError(SNErrorFlag error_flag, const char* pl, int errID){
- if( (error_flag == NO_ERR) || !errID){ // Version
- fprintf(stderr,"%s.\n", ErrorMsg[0]);
- return;
- }
- int len = (pl == NULL) ? 0 : strlen(pl);
-
- delete[] place;
- place = new char[len+1];
-
- if(len) strcpy(place, pl);
- else *place = '\0';
-
- errorFlag = error_flag;
- ErrorHandler(errID);
- }
smmerror.cpp : last modifiled at 2015/11/27 14:48:24(2,130 bytes)
created at 2016/04/11 11:36:47
The creation time of this html file is 2017/10/27 10:59:17 (Fri Oct 27 10:59:17 2017).